package com.nanyang.tms.manager.test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Component;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;

import com.nanyang.tms.dao.saleprice.SalePartDao;
import com.nanyang.tms.domain.saleprice.SalePartDO;
@Component("bManager")
public class BManagerImpl implements BManager{
	@Autowired
    private SalePartDao salePartDao;
	@Autowired
	private DataSourceTransactionManager dataSourceTransactionManager;
	@Autowired
	private TransactionDefinition transactionDefinition;
	@Override
	public void saveB(TransactionStatus transactionStatus) {
		SalePartDO salePartDO=new SalePartDO();
		salePartDO.setPartCode("34343434342");
		salePartDO.setPartName("sdsdsds2");
		salePartDO.setPartSchemeCode("sdsdsdsdsd2");
		salePartDO.setGmtCreatePin("sdsd2");
		salePartDO.setGmtModifiedPin("sdsds2");
		salePartDO.setIp("sdsdssdsd222");
		try {
			if(transactionStatus.isCompleted()){
				transactionStatus=dataSourceTransactionManager.getTransaction(transactionDefinition);
			}
			 salePartDao.insert(salePartDO);
		    int i=10/0;
			dataSourceTransactionManager.commit(transactionStatus);//提交
		} catch (Exception e) {
			dataSourceTransactionManager.rollback(transactionStatus);
			throw e;
		}
	
		
	}

}
